<?php


namespace app\common\model;


use think\Model;

class Withdrawals extends Model
{
    protected $pk = "id";
    // 定义时间戳字段名
    protected $createTime = 'create_time';
    //修改format类型
    protected $dateFormat = "Y-m-d H:i:s";
    protected $type=[
        'money'        =>  'float',
        'taxfee'         =>  'float',
        'true_money'    =>  'float',
    ];
    public function getPkAttr($value,$data) {
        return $this->pk;
    }
    public function user(){
        return $this->hasOne(Users::class, 'user_id','user_id');
    }
    public function getCheckTimeAttr($value) {
        if ($value){
            return date($this->dateFormat,$value);
        }
        return "--";
    }
    public function getRefuseTimeAttr($value) {
        if ($value){
            return date($this->dateFormat,$value);
        }
        return "--";
    }
    public function getRemarkAttr($value) {
        if (empty($value)){
            return "--";
        }
        return $value;
    }
    public function getStatusTextAttr($value,$data) {
        $status = [-1=>'待审核',1=>'审核成功',2=>'审核失败'];
        return $status[$data['status']];
    }
    public function getTypeTextAttr($value,$data) {
        $types = [1=>'粮票'];
        return $types[$data['type']];
    }
    public function getTxTypeTextAttr($value,$data) {
        $types = [1=>'微信',2=>'支付宝',3=>'银行卡'];
        return $types[$data['tx_type']];
    }
    public function getZhangHuAttr($value,$data) {
        switch ($data['tx_type']){
            case 1:
                $zhanghu="微信提现";
                break;
            case 2:
                $zhanghu="{$data['realname']}|{$data['zhifubao']}";
                break;
            case 3:
                $zhanghu="{$data['bank_name']}|{$data['bank_card']}";
                break;
            default:
                $zhanghu="---";
                break;
        }
        return $zhanghu;
    }
}
